/*
 * Write a C++ menu driven program for addition, subtraction, 
 * multiplication and divison.
 */

# include <iostream>
using namespace std;

class MenuCalc{
  int a, b, choice;
public:
  void displayMenu();
  void add();
  void subtract();
  void multiply();
  void divide();
};

void MenuCalc::displayMenu(){
  cout << endl << "********** Calculator Menu ***********" << endl;
  cout << "1. Add" << endl;
  cout << "2. Subtract" << endl;
  cout << "3. Multiply" << endl;
  cout << "4. Divide" << endl;
  cout << "Enter your choice: ";
  cin >> choice;
  cout << "Enter first number: ";
  cin >> a;
  cout << "Enter second number: ";
  cin >> b;
  switch(choice) {
  case 1:
    add();
    break;
  case 2:
    subtract();
    break;
  case 3:
    multiply();
    break;
  case 4:
    divide();
    break;
  default:
    cout << "Invalid choice! Try again...";
    displayMenu();
    break;
  }
}

void MenuCalc::add() {
  cout << "Sum of two numbers: " << a + b << endl;
}

void MenuCalc::subtract() {
  cout << "Difference of two numbers: " << a - b << endl;
}

void MenuCalc::multiply() {
  cout << "Product of two numbers: " << a * b << endl;
}

void MenuCalc::divide() {
  cout << "Fraction of two numbers: " << a / b << endl;
}

int main() {
  char proceed = 'y';
  MenuCalc mc;
  while(proceed == 'y' || proceed == 'Y') {
    mc.displayMenu();
    cout << endl << "Do you want to continue? (Y/N): ";
    cin >> proceed;
  }
  cout << "Thankyou for using this program!" << endl;
  return 0;
}
